import math
from scipy.stats import norm

def bsm_vanilla(spot, strike, r, q, vol, t, option_type):
    d1 = (math.log(spot/strike) + (r-q+0.5*vol*vol)*t)/(math.sqrt(t)*vol)
    d2 = d1 - (math.sqrt(t)*vol)
    if option_type == 'call':
        return  spot*math.exp(-q*t)*norm.cdf(d1) - strike*math.exp(-r*t)*norm.cdf(d2)
    else:
        return strike*math.exp(-r*t)*norm.cdf(-d2) - spot*math.exp(-q*t)*norm.cdf(-d1)